<?php
session_start();

$email = $_POST['email'];
$phone = $_POST['phone'];

include 'dbconnect.php';

  // Check connection
if (mysqli_connect_errno())
  {
  //echo "alert'Failed to connect to MySQL: ' . mysqli_connect_error()";
  }

$result = mysqli_query($con,"SELECT * FROM connections");

$error = 0;

while($row = mysqli_fetch_array($result))
  {
  if ($row['email']==$email && $row['phoneNumber']==$phone){
    $error = 1;
    //Send email..
	$_SESSION['error'] = "An email has been sent to ".$email." with your password details.";
    ?>
		<script type="text/javascript">
			window.location.href = '../../';
		</script>
	<?php
    break;
  }
  }
  
  if ($error != 1){
	$_SESSION['error']="Email or phone number does not exist.";
  ?>
    <script type="text/javascript">
		window.location.href = '../../';
	</script>
<?php
  }
  
mysqli_close($con);
?>